import React, {useState, useEffect} from 'react';
import {View, Text, Button} from 'react-native';
import {Navigation} from 'react-native-navigation';
// let t = 'teset';
export default function ProductDetail(props) {
  // console.log(props.title);

  useEffect(() => {
    setOptions(props);
  });
  return (
    <View>
      <View>
        <Text>产品详细</Text>
        <View>
          <Text>参数：id:{props.id}</Text>
          <Text>参数：title:{props.title}</Text>
        </View>
        <Button
          title="返回"
          onPress={() => {
            Navigation.pop(props.componentId);
          }}></Button>
      </View>
    </View>
  );
}
function setOptions({componentId, title}) {
  // mergeOptions():更改组件或布局的导航选项。动态修改标题。
  // 在组件内，不能通过组件.option = {}来修改title；
  Navigation.mergeOptions(componentId, {
    topBar: {
      title: {
        text: title,
        alignment: 'fill',
      },
    },
  });
}
